<template>
    <div class="container">
        <h4>创建项目</h4><hr style="margin-top:-5px;margin-bottom:10px;">
        <el-form :inline=true>
            <el-form-item label="项目名称">
                <el-input v-model="project_name"></el-input>
            </el-form-item>
            <el-form-item label="项目git">
                <el-input v-model="git_path"></el-input>
            </el-form-item>
            <el-form-item label="成员名称">
                <el-input v-model="member_name"></el-input>
            </el-form-item>
            <el-form-item label="成员角色">
                <el-select v-model="member_role">
                    <el-option :value="member_options.pm"></el-option>
                    <el-option :value="member_options.backend"></el-option>
                    <el-option :value="member_options.frontend"></el-option>
                    <el-option :value="member_options.testers"></el-option>
                    <el-option :value="member_options.operations"></el-option>
                </el-select>
            </el-form-item>
            <el-button type="primary" @click="Save" icon="el-icon-success">保存</el-button>
        </el-form>
    </div>
</template>
<script>
    import { createProject } from '@/api/project'
    import { stringify } from 'qs'
    export default {
        data() {
            return {
                project_name: "",
                git_path: "",
                member_name: "",
                member_role: "",
                member_options: {
                    "pm": "项目经理",
                    "backend": "后端开发",
                    "frontend": "前端开发",
                    "operations": "运维",
                    "testers": "测试"
                }
            }
        },
        created() {

        },
        methods: {
            Save() {
                const formData = stringify({
                    project_name: this.project_name,
                    git_path: this.git_path,
                    member_name: this.member_name,
                    member_role: this.member_role,
                });
                createProject(formData).then(rsp => {
                    console.log("创建成功");
                    this.$message({
                        message: '创建项目成功',
                        type: 'success',
                    })
                }).catch((error) => {
                    console.log(error);
                });
                this.project_name = ""
                this.git_path = ""
                this.member_name = ""
                this.member_role = ""
            },
        },
    }
</script>
<style>
.container {
    margin-left: 40px;
    margin-top: 20px;
}
</style>